package homeword;

import java.util.Scanner;

public class 数字解密 {
    public static void main(String[] args) {

        //输入5位数密码
        int[] password = new int[5];
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的五位数加密后的密码,我们将会解密");
        for (int i = 0; i < password.length; i++) {
            password[i] = scanner.nextInt();
        }
        //将数组反转
        for (int i = 0, j = password.length - 1; i < j; i++, j--) {
            int temp = password[i];
            password[i] = password[j];
            password[j] = temp;
        }
        //进行对余10加密方式来处理
        for (int i = 0; i < password.length; i++) {
            if (password[i] >= 0 && password[i] <= 4) {
                password[i] = password[i] + 10;
            }
        }
        //进行对加5来解密
        for (int i = 0; i < password.length; i++) {
            password[i] -= 5;
        }
        //密码拼接
        int num = 0;
        for (int i = 0; i < password.length; i++) {
            num = num * 10 + password[i];
        }
        System.out.println("解密后你的密码为：" + num);
    }
}
